<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
                    xmlns:System="clr-namespace:System;assembly=mscorlib"
                    xmlns:Vectors="clr-namespace:Assembly.Metro.Controls.Vectors">

    <!-- Metro Button -->
    <Style x:Key="{x:Type Button}" TargetType="{x:Type Button}">
        <Setter Property="Foreground" Value="#999999"/>
        <Setter Property="Background" Value="#222222"/>
        <Setter Property="BorderBrush" Value="#616161"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Padding" Value="0,-2,0,0"/>
        <Setter Property="Height" Value="24"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid x:Name="Grid">
                        <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"/>
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
                    </Grid>

                    <ControlTemplate.Triggers>

                        <!-- Defaulted Button -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="false" SourceName="Grid" />
                                <Condition Property="IsPressed" Value="false" />
                                <Condition Property="IsEnabled" Value="true" />
                                <Condition Property="IsDefaulted" Value="true" />
                            </MultiTrigger.Conditions>
                            <Setter Property="BorderBrush" Value="{DynamicResource ExtryzeAccentBrush}" TargetName="Border"/>
                        </MultiTrigger>

                        <!-- Focused Button -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="false" SourceName="Grid" />
                                <Condition Property="IsPressed" Value="false" />
                                <Condition Property="IsEnabled" Value="true" />
                                <Condition Property="IsDefaulted" Value="true" />
                            </MultiTrigger.Conditions>
                            <Setter Property="BorderBrush" Value="{DynamicResource ExtryzeAccentBrush}" TargetName="Border"/>
                        </MultiTrigger>

                        <!-- Mouse Over -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="true" SourceName="Grid" />
                                <Condition Property="IsPressed" Value="false" />
                                <Condition Property="IsEnabled" Value="true" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" Value="#393939" TargetName="Border"/>
                            <Setter Property="BorderBrush" Value="{DynamicResource ExtryzeAccentBrushSecondary}" TargetName="Border"/>
                        </MultiTrigger>

                        <!-- Mouse Pressed -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="true" SourceName="Grid" />
                                <Condition Property="IsPressed" Value="true" />
                                <Condition Property="IsEnabled" Value="true" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" Value="#333333" TargetName="Border"/>
                            <Setter Property="BorderBrush" Value="{DynamicResource ExtryzeAccentBrushSecondary}" TargetName="Border"/>
                        </MultiTrigger>

                        <!-- Disabled -->
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Background" Value="#FF575757" TargetName="Border"/>
                            <Setter Property="BorderBrush" Value="#FF8B8B8B" TargetName="Border"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Metro Sidebar Header Button -->
    <Style x:Key="SidebarHeaderButton" TargetType="{x:Type Button}">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Height" Value="60"/>
        <Setter Property="FontSize" Value="20"/>
        <Setter Property="Padding" Value="0,0,0,0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid x:Name="Grid">
                        <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"/>
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
                    </Grid>

                    <ControlTemplate.Triggers>

                        <!-- Mouse Over -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="true" SourceName="Grid" />
                                <Condition Property="IsPressed" Value="false" />
                                <Condition Property="IsEnabled" Value="true" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" Value="#3e3e40" TargetName="Border"/>
                        </MultiTrigger>

                        <!-- Mouse Pressed -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="true" SourceName="Grid" />
                                <Condition Property="IsPressed" Value="true" />
                                <Condition Property="IsEnabled" Value="true" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" Value="{DynamicResource ExtryzeAccentBrushSecondary}" TargetName="Border"/>
                        </MultiTrigger>

                        <!-- Disabled -->
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Background" Value="#161616" TargetName="Border"/>
                            <Setter Property="BorderBrush" Value="{DynamicResource ExtryzeAccentBrushSecondary}" TargetName="Border"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Metro Toggle Button -->
    <Style x:Key="PinButton" TargetType="{x:Type ToggleButton}">
        <Setter Property="Foreground" Value="{x:Null}"/>
        <Setter Property="Background" Value="{x:Null}"/>
        <Setter Property="BorderBrush" Value="{x:Null}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Padding" Value="-1,0,0,0"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid x:Name="Grid">
                        <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"/>
                        <Grid x:Name="Pin" RenderTransformOrigin="0.5,0.5" Margin="0,0,0,0" SnapsToDevicePixels="True">
                            <Vectors:PinModule x:Name="PinVector" SnapsToDevicePixels="True" />
                        </Grid>
                        <Rectangle Opacity="0" Fill="White" />
                    </Grid>

                    <ControlTemplate.Triggers>
                        <!-- Mouse Over -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="true" SourceName="Grid" />
                                <Condition Property="IsPressed" Value="false" />
                                <Condition Property="IsEnabled" Value="true" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" Value="{DynamicResource ExtryzeAccentBrushSecondary}" TargetName="Border"/>
                        </MultiTrigger>

                        <!-- Mouse Pressed -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="true" SourceName="Grid" />
                                <Condition Property="IsPressed" Value="true" />
                                <Condition Property="IsEnabled" Value="true" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" Value="{DynamicResource ExtryzeAccentBrush}"/>
                            <Setter Property="Opacity" Value="0.7"/>
                        </MultiTrigger>

                        <!-- Checked Third State -->
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="Pin" Property="RenderTransform">
                                <Setter.Value>
                                    <TransformGroup>
                                        <ScaleTransform/>
                                        <SkewTransform/>
                                        <RotateTransform Angle="-90"/>
                                        <TranslateTransform/>
                                    </TransformGroup>
                                </Setter.Value>
                            </Setter>
                        </Trigger>

                        <!-- Disabled -->
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Background" Value="#161616" TargetName="Border"/>
                            <Setter Property="BorderBrush" Value="{DynamicResource ExtryzeAccentBrushSecondary}" TargetName="Border"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Metro Sidebar Buttom -->
    <Style x:Key="SidebarButton" TargetType="{x:Type ToggleButton}">
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="Background" Value="{x:Null}"/>
        <Setter Property="BorderBrush" Value="#FFA8A8A8"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Height" Value="50"/>
        <Setter Property="FontSize" Value="25"/>
        <Setter Property="FontFamily" Value="{DynamicResource MetroFontLight}"/>
        <Setter Property="Padding" Value="-1,0,0,0"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid x:Name="Grid">
                        <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"/>
                        <Grid x:Name="Pin" RenderTransformOrigin="0.5,0.5" Margin="0,0,0,0" SnapsToDevicePixels="True">
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
                        </Grid>
                    </Grid>

                    <ControlTemplate.Triggers>
                        <!-- Mouse Over -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="true" SourceName="Grid" />
                                <Condition Property="IsPressed" Value="false" />
                                <Condition Property="IsEnabled" Value="true" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" Value="{DynamicResource ExtryzeAccentBrushSecondary}" TargetName="Border"/>
                        </MultiTrigger>

                        <!-- Mouse Pressed -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="true" SourceName="Grid" />
                                <Condition Property="IsPressed" Value="true" />
                                <Condition Property="IsEnabled" Value="true" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" Value="{DynamicResource ExtryzeAccentBrush}" TargetName="Border"/>
                            <Setter Property="Opacity" Value="0.7"/>
                        </MultiTrigger>

                        <!-- Checked Third State -->
                        <Trigger Property="IsChecked" Value="True">
                            <Setter Property="Background" Value="{DynamicResource ExtryzeAccentBrush}" TargetName="Border"/>
                            <Setter Property="Opacity" Value="1.0"/>
                        </Trigger>

                        <!-- Disabled -->
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Background" Value="#161616" TargetName="Border"/>
                            <Setter Property="BorderBrush" Value="{DynamicResource ExtryzeAccentBrushSecondary}" TargetName="Border"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <!-- Metro Textbox -->
    <Style x:Key="{x:Type TextBox}" TargetType="{x:Type TextBox}">
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Height" Value="25"/>
        <Setter Property="FontFamily" Value="{DynamicResource MetroFontRegular}"/>
        <Setter Property="Background" Value="#414141"/>
        <Setter Property="Padding" Value="0,0,0,0"/>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="SelectionBrush"  Value="{DynamicResource ExtryzeAccentBrushSecondary}"/>
        <Setter Property="BorderBrush" Value="#595959"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TextBox}">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="FocusRectangle" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="DisabledVisualElement">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="ReadOnly">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ReadOnlyVisualElement">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="FocusRectangle" />
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="FocusInnerRectangle"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unfocused">
                                    <Storyboard/>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="ValidationStates">
                                <VisualState x:Name="Valid"/>
                                <VisualState x:Name="InvalidUnfocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="ValidationErrorElement">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="InvalidFocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="ValidationErrorElement">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="IsOpen" Storyboard.TargetName="validationTooltip">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <System:Boolean>True</System:Boolean>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Rectangle x:Name="Base" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}" Opacity="1" Fill="{TemplateBinding Background}" />
                        <Rectangle x:Name="FocusRectangle" StrokeThickness="{TemplateBinding BorderThickness}" Opacity="0" Stroke="{x:Null}" />
                        <Rectangle x:Name="FocusInnerRectangle" StrokeThickness="{TemplateBinding BorderThickness}" Opacity="0" Margin="1" Stroke="{x:Null}" />
                        <Grid Margin="0,1,0,0">
                            <Border x:Name="ReadOnlyVisualElement" Background="{x:Null}" Opacity="0"/>
                            <Grid >
                                <ScrollViewer x:Name="PART_ContentHost" BorderThickness="0" IsTabStop="False" Margin="4,2,2,2" VerticalAlignment="Stretch" Background="{x:Null}"/>
                            </Grid>
                        </Grid>
                        <Rectangle x:Name="DisabledVisualElement" Stroke="#FF999999" StrokeThickness="{TemplateBinding BorderThickness}" Fill="#FF999999" IsHitTestVisible="False" Opacity="0"/>
                        <Border x:Name="ValidationErrorElement" BorderBrush="{x:Null}" BorderThickness="1" Visibility="Collapsed">
                            <ToolTipService.ToolTip>
                                <ToolTip x:Name="validationTooltip" DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}" Placement="Right" PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" Template="{DynamicResource ValidationToolTipTemplate}">
                                    <ToolTip.Triggers>
                                        <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                                            <BeginStoryboard>
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="IsHitTestVisible" Storyboard.TargetName="validationTooltip">
                                                        <DiscreteObjectKeyFrame KeyTime="0">
                                                            <DiscreteObjectKeyFrame.Value>
                                                                <System:Boolean>true</System:Boolean>
                                                            </DiscreteObjectKeyFrame.Value>
                                                        </DiscreteObjectKeyFrame>
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </BeginStoryboard>
                                        </EventTrigger>
                                    </ToolTip.Triggers>
                                </ToolTip>
                            </ToolTipService.ToolTip>
                            <Grid Background="Transparent" HorizontalAlignment="Right" Height="12" Margin="1,-4,-4,0" VerticalAlignment="Top" Width="12">
                                <Path Data="M 1,0 L6,0 A 2,2 90 0 1 8,2 L8,7 z" Fill="White" Margin="1,3,0,0"/>
                                <Path Data="M 0,0 L2,0 L 8,6 L8,8" Fill="White" Margin="1,3,0,0"/>
                            </Grid>
                        </Border>
                    </Grid>

                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsEnabled" Value="false" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" Value="#414141"/>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <!-- Metro TextBlock -->
    <Style x:Key="GenericTextblock" TargetType="{x:Type TextBlock}">
        <Setter Property="Foreground" Value="#999999"/>
        <Setter Property="FontFamily" Value="{DynamicResource MetroFontRegular}"/>
    </Style>


    <!-- Metro Expander -->
    <Style x:Key="{x:Type Expander}" TargetType="{x:Type Expander}">
        <Setter Property="Foreground" Value="#999999"/>
        <Setter Property="FontFamily" Value="{DynamicResource MetroFontRegular}"/>
        <Setter Property="Background" Value="#252525"/>
        <Setter Property="BorderBrush" Value="#292929"/>
        <Setter Property="BorderThickness" Value="2"/>
    </Style>
</ResourceDictionary>